﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>排产下发回收页面</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css"> 
        #dvApsPlanInfo .datagrid-cell
        { 
            white-space:normal;
            word-wrap:break-word;           
            word-break: break-all;
        }
    </style>
</head>
<body>
    <div id="mainDiv">
        <div class="panelSection">
            <div class="easyui-panel " title="查询区域" style="padding: 3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div style="margin: 3px 0px 3px 3px">
                    <div style="float: left">
                        <div class="divLabel" style="margin-bottom: 5px">
                            订单号：</div>
                        <input id="txtOrderNum" class="easyui-textbox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            批次号：</div>
                        <input id="txtContainerNum" class="easyui-textbox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            件号：</div>
                        <input id="txtProductNum" class="easyui-textbox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            工序号：</div>
                        <input id="txtSpecNo" class="easyui-textbox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产开始时间：</div>
                        <input id="txtPlanStartTime" class="easyui-datebox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产结束时间：</div>
                        <input id="txtPlanEndTime" class="easyui-datebox" style="width: 120px; height: 20px" />
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                <div style="margin: 3px 0px 3px 3px">
                    <div style="float: left;">
                        <div class="divLabel" style="margin-bottom: 5px">
                            工区：</div>
                        <select style='width: 120px; height: 20px' id='selWorkCenter' data-options='editable:false,panelHeight:80'
                            class='easyui-combobox'>
                        </select>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            班组：</div>
                        <select style='width: 120px; height: 20px' id='selTeam' data-options='editable:false,panelHeight:80'
                            class='easyui-combobox'>
                        </select>
                    </div>
                    <div style="float: left; margin-left: 10px">
                        <div class="divLabel" style="margin-bottom: 5px">
                            排产策略：</div>
                        <select style='width: 80px; height: 20px' id='selApsType' data-options='editable:false,panelHeight:150'
                            class='easyui-combobox'>
                            <option value="" selected>全部</option>
                            <option value="1">正排</option>
                            <option value="2">倒排</option>
                            <option value="3">瓶颈排产</option>
                        </select>
                    </div> 
                    <div style="float: left; margin-left: 10px">
                        <button id="btnSearch" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                            width: 80px;">
                            查询</button>
                        <button id="btnReset" class="easyui-linkbutton" data-options="" style="margin-top: 16px;
                            width: 50px;">
                            重置</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="查询结果" style="padding: 3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div id="dvApsPlanInfo" style="background: #fff; margin: 3px 0px 3px 3px">
                    <div style="width: 99%">
                        <table id="gdApsPlanInfo" class="easyui-datagrid" style="width: 100%; height: 500px;"
                            data-options="rownumbers:true">
                        </table>
                        <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                    layout:['first','prev','next','last','manual','info'],             
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            group:'paging-tail-btns',
                            id:'pageGo'
                    }]  
                ">
                        </div>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
            </div>
        </div>
        <div class="panelSection">
            <div class="easyui-panel " title="按钮区域" style="padding: 3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                <div style="margin: 3px 0px 3px 3px">
                      
                    <div id="divDele" style="float: left; margin-left: 0px">
                        <button id="btnDele" class="easyui-linkbutton" type="button" style="width: 80px;
                            height: 26px">
                            删除</button>
                    </div>
                    <div id="divSendHand" style="float: left; margin-left: 20px">
                        <button id="btnSendHand" class="easyui-linkbutton" type="button" style="width: 200px;
                            height: 26px">
                            发布到工序排产完成情况看板</button>
                    </div>
                    <div id="divEditResult" style="float: left; margin-left: 20px">
                        <button id="btnEditApsResult" class="easyui-linkbutton" type="button" style="width: 150px;
                            height: 26px">
                            排产结果修改</button>
                    </div>
                </div>
            </div>
        </div>
        <div id="statusMessage" style="font-size: 14px; height: 40px">
        </div>
    </div>
    <div id="dg" title="编辑排产结果信息" style="width: 750px; height: 310px; display: none;
        top: 300px" data-options="iconCls:'icon-save',resizable:true">
        <form id="ff">
        <div style="margin: 3px 0 0 3px">
            <div style="float: left">
                <div style="float: left">
                    <div class="divLabel" style="margin-bottom: 5px;">
                        工区：</div>
                    <select id="ddlWorkcenter" name="workcenterId" class="easyui-combobox" data-options="width:170,height:20 "
                        required="required">
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px;">
                        班组：</div>
                    <select id="ddlTeam" name="teamId" class="easyui-combobox" data-options="width:170,height:20, panelHeight:'auto' "
                        required="required">
                    </select>
                </div>
                <div style="clear: both">
                </div>
                <div style="float: left; margin-left: 0px; margin-top: 5px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        排产开始日期</div>
                    <input id="txtStartDate" name="startDate" type="text" class="easyui-datetimebox"
                        style="height: 20px; width: 170px" required="required" />
                </div>
                <div style="float: left; margin-left: 10px; margin-top: 5px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        排产结束日期</div>
                    <input id="txtEndDate" name="endDate" type="text" class="easyui-datetimebox" style="height: 20px;
                        width: 170px" required="required" />
                </div>
                <div style="clear: both">
                </div>
                <div style="float: left; margin-left: 0px; margin-top: 5px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        设备开始日期</div>
                    <input id="txtResStartDate" name="resStartDate" type="text" class="easyui-datetimebox"
                        style="height: 20px; width: 170px" required="required" />
                </div>
                <div style="float: left; margin-left: 10px; margin-top: 5px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        设备结束日期</div>
                    <input id="txtResEndDate" name="resEndDate" type="text" class="easyui-datetimebox"
                        style="height: 20px; width: 170px" required="required" />
                </div>
            </div>
            <div style="float: left; margin-left: 0px; width: 300px">
                <div class="divLabel" style="margin-bottom: 5px;">
                    设备：</div>
                <select id="ddlResource" name="resourceId" class="easyui-combobox" data-options="width:150,height:20 "
                    required="required">
                </select> 
            </div>
        </div>
            <div style="clear: both">
            </div>
        <div style="margin-left:3px;text-align:center;margin-top:10px">
            <button id="btnSave" class="easyui-linkbutton" type="button" style="width: 100px;
                height: 26px">
                保存</button>
            <button id="btnClose" class="easyui-linkbutton" type="button" style="width: 60px;
                height: 26px">
                关闭</button>
        </div> 
        </form>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">

    var page = {
        url: getRootPath() + "/Ashx/ApsHandler/ApsPlanDownSendHandler.ashx", //后台处理url,
        commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx", //通用方法后台路径
        //分页参数
        pagetotal: 0,
        pageSize: 50,
        pageNumber: 1,
        apsPlanDetailID: "", //编辑弹窗选择的主数据
        init: function () {
            page.bind();
            page.bindWorkCenter();
            NewcustomizedEasyuiPagination('pp'); //定制化分页
            $('#pp').find('.pageSize').val(page.pageSize); //初始化行数
        },
        bind: function () {
            //列表加载
            $("#gdApsPlanInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    NewcustomizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单号', width: 120 },
                 { field: 'CONTAINERNAME', title: '批次', width: 150 },
                 { field: 'DESCRIPTION', title: '零件名称', width: 100 },
                 { field: 'QTY', title: '在制数', width: 50 },
                 { field: 'APSQTY', title: '排产数', width: 50 },
                 { field: 'RESOURCEDESC', title: '设备', width: 100 },
                 { field: 'WORKFLOWINFO', title: '工艺', width: 170 },
                 { field: 'WORKFLOWNAME', title: '工艺', width: 150, hidden: true },
                 { field: 'SPECNO', title: '工序号', width: 60, hidden: true },
                 { field: 'WORKFLOWSTEPNAME', title: '排产工序', width: 150 },
                 { field: 'CONTAINERTYPENAME', title: '流水卡类型', width: 80 },
                 { field: 'APSTYPENAME', title: '排产策略', width: 70 },
                 { field: 'STARTTIME', title: '排产开始时间', width: 130,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm');
                         }
                     }
                 },
                 { field: 'ENDTIME', title: '排产结束时间', width: 130,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD HH:mm');
                         }
                     }
                 }
                ]]
            });
            //列表分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    NewcustomizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.search();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                clearMessage();
                var pageNumber = Number($(this).parents('tr').find('.pagination-num').val());
                page.pageSize = $('#pp').find('.pageSize').val() == "" ? 50 : Number($('#pp').find('.pageSize').val());
                page.pageNumber = pageNumber;
                page.search();
            });
            //查询信息
            $("#btnSearch").on("click", function () {
                page.reset(false, true, true);
                page.pageNumber = 1;
                page.search();
            });
            //重置查询
            $("#btnReset").on("click", function () {
                page.reset(true, true, true);
            });
            //删除
            $("#btnDele").on("click", function () {
                page.planDele();
            });
            //下发
            $("#btnSendHand").on("click", function () {
                clearMessage();
                page.planSendHand();
            });
            //编辑排产数据
            $("#btnEditApsResult").on("click", function () {
                page.reset(false, false, true);
                page.openEditApsData();
            });
            //设备初始化
            $("#ddlResource").combobox({
                valueField: 'RESOURCEID',
                textField: 'RESNAME',
                panelHeight: 200
            });
            //保存（窗体）
            $("#btnSave").on("click", function () {
                page.updateTryApsPlanDetail();
            });
            //关闭（窗体）
            $("#btnClose").on("click", function () {
                $("#dg").dialog("close");
            });
        },
        //修改排产数据
        updateTryApsPlanDetail: function () {
            var selectData = $("#gdApsPlanInfo").datagrid('getChecked'); //获取勾选的行

            var param = {
                APSPLANDETAILID: selectData[0].APSPLANDETAILID,
                WORKCENTERID: $("#ddlWorkcenter").combobox('getValue'),
                RESOURCEID: $("#ddlResource").combobox('getValue'),
                TEAMID: $("#ddlTeam").combobox('getValue'),
                STARTTIME: $('#txtStartDate').datetimebox('getValue'),
                ENDTIME: $('#txtEndDate').datetimebox('getValue'),
                RESSTARTTIME: $('#txtResStartDate').datetimebox('getValue'),
                RESENDTIME: $('#txtResEndDate').datetimebox('getValue')
            };

            if (isNullOrWhiteSpaceStr(param.WORKCENTERID) || isNullOrWhiteSpaceStr(param.STARTTIME) || isNullOrWhiteSpaceStr(param.ENDTIME) ||
            isNullOrWhiteSpaceStr(param.RESSTARTTIME) || isNullOrWhiteSpaceStr(param.RESENDTIME)) {
                displayMessage("请填入必填字段", false,true);
                return;
            }

            if (dayjs(param.ENDTIME) < dayjs(param.STARTTIME)) {
                displayMessage("开始时间不能大于结束时间", false,true);
                return;
            }
            if (dayjs(param.RESENDTIME) < dayjs(param.RESSTARTTIME)) {
                displayMessage("开始时间不能大于结束时间", false,true);
                return;
            }
            var params = [];
            params.push(param);
            var formData = {
                action: "updateTryPlanDetail",
                params: JSON.stringify(params)
            };
            //console.log(formData);
            $.ajax({
                type: "Post",
                url: page.url,
                data: formData,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        displayMessage("保存成功", true);
                        page.search();
                        $("#dg").dialog("close");
                    } else {
                        displayMessage(result.Message, false,true);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //编辑排产数据
        openEditApsData: function () {

            var selectData = $("#gdApsPlanInfo").datagrid('getChecked'); //获取勾选的行
            if (selectData.length > 1) {
                displayMessage("请选择单行数据", false);
                return;
            } else if (selectData.length == 0) {
                displayMessage("请选择数据", false);
                return;
            }
            //console.log(selectData);
            $('#dg').dialog({
                title: '数据编辑',
                fit: false,
                width: 400,
                height: 250,
                closed: false,
                cache: false,
                modal: true,
                onOpen: function () {
                    //赋值
                    $("#ddlWorkcenter").combobox('select', selectData[0].WORKCENTERID);
                    $('#txtStartDate').datetimebox('setValue', selectData[0].STARTTIME);
                    $('#txtEndDate').datetimebox('setValue', selectData[0].ENDTIME);
                    $('#txtResStartDate').datetimebox('setValue', selectData[0].RESSTARTTIME);
                    $('#txtResEndDate').datetimebox('setValue', selectData[0].RESENDTIME);
                    page.loadResource(selectData[0].SPECID, selectData[0].RESOURCEID);
                    $("#ddlTeam").combobox('select', selectData[0].TEAMID);
                },
                onClose: function () {

                }
            });
        },
        //绑定工区
        bindWorkCenter: function () {

            $.ajax({
                type: "Post",
                url: page.commonUrl,
                data: { action: "GetWorkcenterOfDefault" },
                cashe: false,
                async: true,
                beforeSend: function () {

                },
                success: function (data) {
                    var res = JSON.parse(data);
                    //绑定查询工区下拉框
                    var workCenter = res.DBTable;
                    workCenter.splice(0, 0, { WORKCENTERNAME: "请选择", WORKCENTERID: "", NOTES: null, WCTYPE: null });
                    $("#selWorkCenter").combobox({
                        valueField: 'WORKCENTERID',
                        textField: 'WORKCENTERNAME',
                        panelHeight: 200,
                        data: workCenter, //res.DBTable, //下拉数据
                        onSelect: function (record) {
                            page.bindTeam(record.WORKCENTERID, 1); //加载班组
                        }
                    });
                    if (res.ReturnData != null) {
                        $("#selWorkCenter").combobox("setValue", res.ReturnData); //默认值      
                    }
                    //绑定弹窗工区下拉框
                    $("#ddlWorkcenter").combobox({
                        valueField: 'WORKCENTERID',
                        textField: 'WORKCENTERNAME',
                        panelHeight: 200,
                        data: res.DBTable, //下拉数据
                        onSelect: function (record) {
                            page.bindTeam(record.WORKCENTERID, 2); //加载班组
                        }
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                    alert(XMLHttpRequest.responseText);
                }
            });

        },
        //绑定查询班组(type:1,查询，2,弹窗)
        bindTeam: function (workCenterId, type) {
            $.ajax({
                type: "Post",
                url: page.commonUrl,
                data: { action: "GetTeam", workCenterId: workCenterId },
                cashe: false,
                async: true,
                beforeSend: function () {

                },
                success: function (data) {
                    var res = JSON.parse(data);
                    if (type === 1) {
                        //绑定班组
                        $("#selTeam").combobox({
                            valueField: 'TEAMID',
                            textField: 'TEAMNAME',
                            panelHeight: 200,
                            data: res.DBTable //下拉数据
                        });
                        if (res.ReturnData != null) {
                            $("#selTeam").combobox("setValue", res.ReturnData); //默认值      
                        }
                    }
                    else {
                        //绑定班组
                        $("#ddlTeam").combobox({
                            valueField: 'TEAMID',
                            textField: 'TEAMNAME',
                            panelHeight: 200,
                            data: res.DBTable //下拉数据
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                    alert(XMLHttpRequest.responseText);
                }
            });

        },
        //加载设备
        loadResource: function (specid, selValue) {
            if (isNullOrWhiteSpaceStr(specid)) {
                return;
            }
            //console.log('select workcenter'); 
            $("#ddlResource").combobox('clear');

            $.ajax({
                type: "Get",
                url: page.commonUrl + "?action=getResourceBySpec&specId=" + specid,
                cashe: false,
                async: false, //同步
                beforeSend: function () {

                },
                success: function (data) {
                    $("#ddlResource").combobox('loadData', JSON.parse(data));
                    if (!isNullOrWhiteSpaceStr(selValue)) {
                        $("#ddlResource").combobox('select', selValue);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //查询
        search: function () {
            var gridID = "#gdApsPlanInfo";
            clearEasyuiDataGrid("gdApsPlanInfo");
            var params = [{
                mfgOrderName: $("#txtOrderNum").textbox("getValue"), //订单号
                containerName: $("#txtContainerNum").textbox("getValue"), //批次号
                productName: $("#txtProductNum").textbox("getValue"), //件号
                specNo: $("#txtSpecNo").textbox("getValue"), //工序号
                startTime: $("#txtPlanStartTime").textbox("getValue"), //开始时间
                endTime: $("#txtPlanEndTime").textbox("getValue"), //结束时间
                apsType: $("#selApsType").combobox("getValue"), //排产策略
                workCenter: $("#selWorkCenter").combobox("getValue"), //工区
                team: $("#selTeam").combobox("getValue") //班组
            }];
            var formData = {
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                action: "getTryApsPlanDetailData",
                params: JSON.stringify(params)
            };
            //console.log(formData);
            $.ajax({
                type: "Post",
                url: page.url,
                data: formData,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $(gridID).datagrid('loading');
                    $(this).attr("disabled", "disabled"); //禁用按钮
                },
                success: function (data) {
                    //console.log(data);
                    $(gridID).datagrid('loaded');
                    $(this).removeAttr("disabled"); //恢复按钮
                    var result = JSON.parse(data);
                    if (result.Result) {
                        //给分页对象赋值
                        page.pagetotal = result.RowCount;
                        $(gridID).datagrid('loadData', { total: result.RowCount, rows: result.DBTable });
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $(gridID).datagrid('loaded');
                    $(this).removeAttr("disabled"); //恢复按钮
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //计划删除
        planDele: function () {
            var rows = $("#gdApsPlanInfo").datagrid('getChecked'); //获取勾选的行
            if (rows.length == 0) {
                displayMessage("请选择数据", false);
                return;
            }
            //console.log(rows);
            //return;
            var formData = {
                action: "delTryApsPlanDetail",
                params: JSON.stringify(rows.map(function (item) {
                    return {
                        containerId: item.CONTAINERID,
                        workflowstepId: item.WORKFLOWSTEPID,
                        apsplandetailId: item.APSPLANDETAILID,
                        apsType: item.APSTYPE
                    }
                }))
            };
            //console.log(formData);
            $.ajax({
                type: "Post",
                url: page.url,
                data: formData,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        displayMessage("删除成功", true);
                        page.search();
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //发送到手动排产表
        planSendHand: function () {
            var rows = $("#gdApsPlanInfo").datagrid('getChecked'); //获取勾选的行
            if (rows.length == 0) {
                displayMessage("请选择数据", false);
                return;
            }

            var formData = {
                action: "sendTryApsToHand",
                datas: JSON.stringify(rows.map(function (item) {
                    return {
                        containerId: item.CONTAINERID,
                        workflowstepId: item.WORKFLOWSTEPID,
                        apsplandetailId: item.APSPLANDETAILID,
                        workflowstepName: item.WORKFLOWSTEPNAME,
                        apsType: item.APSTYPE
                    }
                }))
            };
            //console.log(formData);
            $.ajax({
                type: "Post",
                url: page.url,
                data: formData,
                cashe: false,
                async: true,
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    var result = JSON.parse(data);
                    if (result.Result) {
                        displayMessage(result.Message, true);
                        page.search();
                    } else {
                        displayMessage(result.Message, false);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    alert(XMLHttpRequest.responseText);
                }
            });
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult, isDetail) {
            clearMessage();
            if (iscondition) {
                $("#txtOrderNum").textbox("setValue", ""); //订单号
                $("#txtContainerNum").textbox("setValue", ""); //批次号
                $("#txtProductNum").textbox("setValue", ""); //件号
                $("#txtPlanStartTime").textbox("setValue", ""); //排产开始时间
                $("#txtPlanEndTime").textbox("setValue", ""); //排产结束时间
                $("#txtSpecNo").textbox("setValue", ""); //工序号
                $("#selApsType").combobox("setValue", ""); //排产策略 
                page.bindWorkCenter();
            }

            if (isresult) {
                clearEasyuiDataGrid("gdApsPlanInfo", 1); //查询结果列表
                page.pageNumber = 1; page.pagetotal = 0; //重置分页
                $('#pp').pagination('refresh', {
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            }

            if (isDetail) {
                $("#ddlWorkcenter").combobox('select', '');
                $("#ddlTeam").combobox('select', '');
                $("#ddlResource").combobox('loadData', []);
                $('#txtStartDate').datetimebox('clear');
                $('#txtEndDate').datetimebox('clear');
                $('#txtResStartDate').datetimebox('clear');
                $('#txtResEndDate').datetimebox('clear');
            }
        }
    }

    $(function () {
        page.init();
    });
</script>
